package com.example.demo.rx;

import com.example.demo.rx.cat.SApi;
import com.example.demo.rx.cat.Cat;

import java.net.URL;
import java.util.Collections;
import java.util.List;

public class CatsHelper0 {
    SApi api;
    public URL saveTheCutestCat(String query) {
        try {
            List<Cat> cats = api.queryCat(query);
            Cat cutest = findCutest(cats);
            URL saveUrl = api.store(cutest);
            return saveUrl;
        }catch (Exception e) {
            e.fillInStackTrace();
            return null;
        }
    }

    private Cat findCutest(List<Cat> cats) {
        return Collections.max(cats);
    }
}
